package com.hbfec.mqttmanager.mapper;

import com.hbfec.mqttmanager.entity.MessageEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface MessageMapper {
    @Insert("INSERT INTO user_chatlog(topic,sender,receiver,payload,created) " +
            "VALUES(#{topic}, #{sender}, #{receiver},#{payload},#{created})")
    void insert(MessageEntity msg);

    @Select("SELECT payload FROM user_chatlog WHERE sender = #{user} or receiver = #{user}")
    List<String> getAll(String user);
}
